/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client;

import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import com.jme3.scene.control.Control;
import java.util.ArrayList;
import java.util.Random;
/**
 *
 * @author Ben
 */
public class ControlNpc extends AbstractControl
{
    protected ArrayList<Spatial> Targets;
    protected long thinkInterval = 2L;
    protected long thinkRandomness = 3L;
    protected long nowTime;
    protected long lastTime;
    protected int maxTargets = 4;
    protected STATE myState;
    protected boolean lookAt = true;
    protected boolean first = true;
    protected Spatial thisNpc = this.getSpatial();
    protected randomGenerator rand = new randomGenerator(10);
    protected randomGenerator stateRand = new randomGenerator(STATE.values().length);
    
    enum STATE
    {
        STATE_IDLE,STATE_MOVING,STATE_THINKING
    }
    
    private class randomGenerator
    {
        protected Random random = new Random();
        protected int randomChance;
        
        randomGenerator(int input)
        {
            input = randomChance;
            random.setSeed(randomChance);
        }
        
        public float fakeRandom()
        {
            float a = random.nextFloat();
            float ab = a*10;
            float b = Math.round(ab);
            return b;
        }
        
        public boolean fakeBoolean()
        {
            return random.nextBoolean();
        }
    }
    
    

    @Override
    protected void controlUpdate(float tpf)
    {
        if(first)
        {
            lastTime = System.currentTimeMillis();
            first = false;
        }
        nowTime = System.currentTimeMillis();
        if(nowTime > lastTime + (thinkInterval*1000))
        {
            if(rand.fakeBoolean())
            {
                myState = STATE.STATE_THINKING;
            }
            else
            {
                myState = STATE.STATE_IDLE;
            }
            lastTime = System.currentTimeMillis();
        }
    }

    @Override
    protected void controlRender(RenderManager rm, ViewPort vp)
    {
        
    }

    public Control cloneForSpatial(Spatial spatial)
    {
        return null;
    }
    
}
